$def with(form, saved = None)
$:render.admin.header(scripts=['scripts/libs/jquery.tools.min.js','scripts/libs/fancybox/jquery.fancybox-1.3.4.pack.js'],css=['admin/css/ui.css','scripts/libs/fancybox/jquery.fancybox-1.3.4.css'])

<script type="text/javascript">
    $$(function () {
        $$('._fancybox').fancybox({
                'autoScale': true,
                'type': 'iframe',
                'width': 670,
                'height': 388
            });
        $$('#validator_link').fancybox();
        form_validator();
    });
    function form_validator() {
        $$.tools.validator.addEffect('wall', function(errors, event) {
            // 获取错误容器
            var wall = $$(this.getConf().container);
            // 移除所有已经有的信息
            wall.find('p').remove();
            // 附加么一条信息
            $$.each(errors, function(index, error) {
                // 附加错误信息到容器中
                wall.append(
                    '<p>' + (index + 1) + '. ' + error.messages[0] + '</p>'
                );
                // 在错误控件上，添加一个标识无效的class
                error.input.addClass('invalid');
            });
            $$('#validator_link').trigger('click');

        }, function(inputs) {
            // 该方法中处理输入有效的控件
            $$.each(inputs, function(index, input) {
                // 去掉标识无效的class
                $$(input).removeClass('invalid');
            });
        });
        $$('form').validator({
                'messageAttr': 'message',
                'effect': 'wall',
                'container': '#errors'
        });
    };
    // media uploader callback
    function media_selected(id, thumbnail) {
        if (id > 0) {
            $$('#logo').val(id.toString());
            var t = $$('#thumbnail');
            t.show();
            t.html('<img src="' + thumbnail + '" />');
            $$.fancybox.close();
        }
    }
</script>

<a href="#errors" style="display:none;" id="validator_link"></a>
<div id="error_container" style="display:none;">
    <div id="errors">
        <h2>请先修复以下问题</h2>
    </div>
</div>

<div class="itemtitle">
    <h3>$:form.submit.attrs['html']</h3>
    <ul class="tab1">
        <li><a href="/admin/partner"><span>管理</span></a></li>
        <li class="current"><a href="javascript:void(0);"><span>添加</span></a></li>
    </ul>
</div>
$if saved:
    $if saved == 'true':
        <div style="color:green;">保存成功！！</div>
    $else:
        <div style="color:red">保存失败！！</div>
    
<form method="post" action="">
<table class="tb tb2">
    <tr><td class="td27" colspan="2">名称：</td></tr>
    <tr class="noborder">
        <td class="vtop rowform">$:form.name.render()</td>
        <td class="vtop tips2">标题长度请控制在16个汉字，32个字符以内。</td>
    </tr>
    <tr><td class="td27" colspan="2">LOGO：</td></tr>
    <tr class="noborder">
        <td class="vtop rowform">
            $if form.logo.value:
                <div id="thumbnail"><img src="$:get_media_url(form.logo.value)" /></div>
            $else:
                <div id="thumbnail" style="display:none"></div>
            <a href="/admin/media/upload" class="_fancybox">设置LOGO</a>$:form.logo.render()</td>
        <td class="vtop tips2">点击“<a href="/admin/media/upload" class="_fancybox">设置LOGO</a>”选择或上传商家</td>
    </tr>
    <tr><td class="td27" colspan="2">域名：</td></tr>
    <tr class="noborder">
        <td class="vtop rowform">$:form.domain.render()</td>
        <td class="vtop tips2">请只输入商家域名，而不包括“http://”等内容。</td>
    </tr>
    <tr><td class="td27" colspan="2">推广路径模板：</td></tr>
    <tr class="noborder">
        <td class="vtop rowform">$:form.spread_url.render()</td>
        <td class="vtop tips2">使用%(url)s标识出需要替换每一条信息地址的位置。</td>
    </tr>
    <tr><td class="td27" colspan="2">排序值：</td></tr>
    <tr class="noborder">
        <td class="vtop rowform">$:form.sort.render()</td>
        <td class="vtop tips2">列表中，商家将按此字段降序排列。</td>
    </tr>
    <tr><td colspan="2">$:form.submit.render()</td></tr>
</table>
</form>

$:render.admin.footer()
